function whenDocumentReady(){
	$('#storeUl li').hover(function(){	
		$(this).find('p').animate({'top':'60px'},400); 
	},function(){
		$(this).find('p').stop(); 
		$(this).find('p').animate({'top':'120px'},400); 
	});
	$(".schoolSearch_text").keydown(function(e){
		if(e.keyCode==13){
			getSchools();
		}
	});
	/*添加图片地址*/
	$(".adv-img").each(function(){
		$(this).attr("src","/images/ad/ad_"+$(this).attr("data")+".jpg?t="+parseInt(new Date().getTime()/3600000));
	});
}
function slideUl(data,button){
	$(button).attr("disabled","disabled");
	setTimeout(function(){
		$(button).removeAttr("disabled");
	},500);
	var ulLeft=parseInt($("#resultUl").css("left"));
	var ulWidth=$("#resultUl").width();
	var visibleWidth=1000;
	if(data==0){
		$("#resultUl").animate({left:(ulLeft+visibleWidth)+"px"},500);
		if(ulLeft+visibleWidth==0){
			$(".leftArrow").removeAttr("onclick").addClass("unLeft");
		}
		$(".rightArrow").attr("onclick","slideUl('1',$(this))").removeClass("unRight");
	}else{
		$("#resultUl").animate({left:(ulLeft-visibleWidth)+"px"},500);
		if(-1*ulLeft+visibleWidth*2==ulWidth){
			$(".rightArrow").removeAttr("onclick").addClass("unRight");
		}
		$(".leftArrow").attr("onclick","slideUl('0',$(this))").removeClass("unLeft");
	}
}
function getSchools(){
	var name=$(".schoolSearch_text").val();
	if(name==""){
		return;
	}
	$.ajax({
		type:"POST",
		url:_appRoot+"/browse/school",
		data:{name:name},
		dataType:"json",
		success: function(data){
			if(data.result==0){
				clickautohide(data.message,3);
			}else{
				var schoolHtml="";
				for(var i=0;i<data.length;i++){
					var schoolHtml="<li><a href='../../school/-+data[i].userId+-.htm'/*tpa=http://www.yxit.net/school/"+data[i].userId+".htm*/>";
					schoolHtml+="<img class='result_img' src='"+_picRoot+data[i].userIco+"'/>";
					schoolHtml+="<p>"+data[i].nickName+"</p></a></li>";
				}
				$("#context_div").hide();
				$("#school_div").show();
				if(data.length<=4){
					$(".rightArrow").removeAttr("onclick").addClass("unRight");
				}else{
					$(".rightArrow").attr("onclick","slideUl('1',$(this));").removeClass("unRight");
				}
				$("#resultUl").html(schoolHtml);
				var rows=Math.ceil($("#resultUl li").length*250/1000);
				$("#resultUl").css("width",rows*1000+"px");
			}
		}
	});
}

//登录成功调用函数
function eventJudge(user){
	var userType=user.userType;
	if(userType<2){
		alert("您的账号非企业账号");
		location.reload();
	}else if(userType==2){
		window.location.href=_appRoot+"/userCenter/companyIdentify.html";
	}else{
		window.location.href=_appRoot+"/userCenter/schoolApply.html";
	}
}
